#ifndef EDITCOLLISIONSHAPESVIEW_H
#define EDITCOLLISIONSHAPESVIEW_H

#include <QWidget>

class Texture;
class Animation;
class CollisionShapesDocument;
class CollisionShape;
class CollisionShapeTool;

class EditCollisionShapesView : public QWidget
{
    Q_OBJECT
public:
    explicit EditCollisionShapesView(QWidget *parent = 0);
    ~EditCollisionShapesView();

    void setCollShapesDoc(QPointer<CollisionShapesDocument> doc);
    QPointer<CollisionShapesDocument> collisionShapesDocument() const;

    float zoomFactor() const;
    QPointF viewOrigin() const;
private:
    void paintEvent(QPaintEvent *);
    void resizeEvent(QResizeEvent *pEvent);
    void mousePressEvent(QMouseEvent *pEvent);
    void mouseMoveEvent(QMouseEvent *pEvent);
    void mouseReleaseEvent(QMouseEvent *pEvent);
    void keyPressEvent(QKeyEvent *pEvent);

    void updateHelperGrid();
    void drawGraphicsObjectImage(QPainter& painter);
    void drawShapes(QPainter& painter);

    void wheelEvent(QWheelEvent *pEvent);

    QColor m_backgroundColor;
    QColor m_gridColor;
    float  m_fGridSpacing;

    QPixmap m_pixGrid;
    bool m_bShowGrid;
    QPointF m_oldMousePos;

    QPointer<CollisionShapesDocument> m_csDoc;
    QPointer<CollisionShapeTool> m_currentTool;

    float m_fZoomFactor;
    bool m_bPanning;
    QPointF m_viewOrigin;

    QCursor m_savedCursor;
signals:
    
public slots:
    void setGridColor(const QColor& color);
    void setBackgroundColor(const QColor& color);
    void setShowGrid(bool bShow);
    void setGridSpacing(float size);

    void drawAxis(QPainter& painter);

    void updateView();
    void zoomIn();
    void zoomOut();
    void resetView();

    void setCurrentTool(QPointer<CollisionShapeTool> curTool);
};

#endif // EDITCOLLISIONSHAPESVIEW_H
